package com.jiyun.h2303b.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiyun.h2303b.dao.AccountMapper;
import com.jiyun.h2303b.pojo.TbAccount;
import com.jiyun.h2303b.service.AccountService;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, TbAccount> implements AccountService {
    @Override
    public void debit(int userId, int money) {
        QueryWrapper<TbAccount> query = new QueryWrapper<>();
        query.eq("user_id",userId);
        TbAccount tbAccount = this.baseMapper.selectOne(query);
        tbAccount.setMoney(tbAccount.getMoney()-money);
        this.baseMapper.updateById(tbAccount);
    }
}
